package com.tutu.service.impl;

import com.tutu.core.api.DisplayScreenInfoApiUrls;
import com.tutu.service.DisplayScreenInfoService;
import com.tutu.utils.HttpRequestUtil;
import com.tutu.utils.UnicodeUtil;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Service
public class DisplayScreenInfoServiceImpl implements DisplayScreenInfoService {

    @Override
    public Map<String, Object> pageByParams(String keyWord, Integer pageNum, Integer pageSize) {
        return HttpRequestUtil.getOnlyData(DisplayScreenInfoApiUrls.base_prefix + DisplayScreenInfoApiUrls.page, "keyWord=" + UnicodeUtil.unicodeEncode(keyWord) + "&pageNum=" + pageNum + "&pageSize=" + pageSize);
    }

    @Override
    public Map<String, Object> saveInfo(HttpServletRequest request, Integer id, String accessToken, String content) {
        LogInfoServiceImpl.saveLogInfo(request, "编辑公示屏信息，ID：" + id + "，授权编码：" + accessToken + "，授权描述：" + content);

        return HttpRequestUtil.getCompleteData(DisplayScreenInfoApiUrls.base_prefix + DisplayScreenInfoApiUrls.update, "accessToken=" + accessToken + "&content=" + UnicodeUtil.unicodeEncode(content) + "&id=" + id);
    }

    @Override
    public Map<String, Object> delInfo(HttpServletRequest request, Integer id) {
        LogInfoServiceImpl.saveLogInfo(request, "删除公示屏信息，ID：" + id);

        return HttpRequestUtil.getCompleteData(DisplayScreenInfoApiUrls.base_prefix + DisplayScreenInfoApiUrls.delete, "id=" + id);
    }
}